<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>网易云音乐</title>
  <link rel="shortcut icon" href="./images/favicon (1).ico">
  <link rel="stylesheet" href="./main.css">
  <link rel="stylesheet" href="./header.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
</head>

<body>
  <!-- 头部 -->
  <div class="header">
    <div class="m-top">
      <div class="warp">
        <div class="logo">
          <a href="#">
            <img src="./images/logo.png" alt="">
          </a>
        </div>
        <ul class="m-nav">
          <li class="fst">
            <span>
              <a href="#" class="z-slt">
                <em>发现音乐</em>
                <sub class="cor">&nbsp;</sub>
              </a>
            </span>
          </li>
          <li>
            <span>
              <a href="#">
                <em>我的音乐</em>
                <sub class="cor">&nbsp;</sub>
              </a>
            </span>
          </li>
          <li>
            <span>
              <a href="#">
                <em>关注</em>
                <sub class="cor">&nbsp;</sub>
              </a>
            </span>
          </li>
          <li>
            <span>
              <a href="#">
                <em>商城</em>
                <sub class="cor">&nbsp;</sub>
              </a>
            </span>
          </li>
          <li>
            <span>
              <a href="#">
                <em>音乐人</em>
                <sub class="cor">&nbsp;</sub>
              </a>
            </span>
          </li>
          <li>
            <span>
              <a href="#">
                <em>云推歌</em>
                <sub class="cor">&nbsp;</sub>
              </a>
            </span>
          </li>
          <li>
            <span>
              <a href="#">
                <em>下载客户端</em>
                <sub class="cor">&nbsp;</sub>
              </a>
            </span>
          </li>
        </ul>
        <div class="login">
          <a href="#" class="link">登录</a>
        </div>
        <a href="#" class="creation">创作者中心</a>
        <div class="search">
          <div class="srchbg">
            <img src="./images/searchbg.png" alt="">
            <span class="parent">
              <input type="text">
              <label for="">音乐/视频/电台/用户</label>
            </span>
          </div>
        </div>
      </div>
    </div>
    <div class="top-b">
      <div class="wrap">
        <ul class="nav-b">
          <li>
            <a href="#" class="z-slt">
              <em>推荐</em>
            </a>
          </li>
          <li>
            <a href="#">
              <em>排行榜</em>
            </a>
          </li>
          <li>
            <a href="#">
              <em>歌单</em>
            </a>
          </li>
          <li>
            <a href="#">
              <em>主播电台</em>
            </a>
          </li>
          <li>
            <a href="#">
              <em>歌手</em>
            </a>
          </li>
          <li>
            <a href="#">
              <em>新碟上架</em>
            </a>
          </li>
        </ul>
      </div>
    </div>
  </div>
  <!-- 主体 -->
  <main>
    <div class="slider">
      <div class="n-ban">
        <div class="wrap">
          <div class="ban">
            <div class="ban-img">
              <a href="#">
                <img src="./images/s1.jpg" alt="">
              </a>
            </div>
            <button class="prev">
              <i class="fas fa-chevron-left"></i>
            </button>
            <button class="next">
              <i class="fas fa-chevron-right"></i>
            </button>
            <ul class="dots">
              <li class="is-dots active">
                <div></div>
              </li>
              <li class="is-dots">
                <div></div>
              </li>
              <li class="is-dots">
                <div></div>
              </li>
              <li class="is-dots">
                <div></div>
              </li>
              <li class="is-dots">
                <div></div>
              </li>
              <li class="is-dots">
                <div></div>
              </li>
              <li class="is-dots">
                <div></div>
              </li>
              <li class="is-dots">
                <div></div>
              </li>
              <li class="is-dots">
                <div></div>
              </li>
              <li class="is-dots">
                <div></div>
              </li>
            </ul>
          </div>
          <div class="download">
            <a href="#"><img src="./images/download.png" alt=""></a>
          </div>

        </div>
      </div>
    </div>
    <div class="main-container">
      <div class="g-mn1">
        <div class="g-mn1c">
          <div class="g-wrap">
            <div class="v-hd">
              <a href="#" class="tit">热门推荐</a>
              <div class="tab">
                <a href="#" style="color:#666">华语</a>
                <span style="margin: 0 10px;color: #ccc;">|</span>
                <a href="#" style="color:#666">流行</a>
                <span style="margin: 0 10px;color: #ccc;">|</span>
                <a href="#" style="color:#666">摇滚</a>
                <span style="margin: 0 10px;color: #ccc;">|</span>
                <a href="#" style="color:#666">民谣</a>
                <span style="margin: 0 10px;color: #ccc;">|</span>
                <a href="#" style="color:#666">电子</a>
                <span style="margin: 0 10px;color: #ccc;">|</span>
              </div>
              <span class="more">
                <a href="#" style="color: #666;">更多</a>
                <i class="cor" style="color:red">&nbsp;</i>
              </span>
            </div>
            <ul class="mscvlst">
              <li>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </main>
  <!-- 轮播图 -->
  <script>
    document.addEventListener('DOMContentLoaded', function () {
      // 1. 初始数据
      const sliderData = [
        { url: './images/s1.jpg', bg: './images/sb1.jpg' },
        { url: './images/s2.jpg', bg: './images/sb2.jpg' },
        { url: './images/s3.jpg', bg: './images/sb3.jpg' },
        { url: './images/s4.jpg', bg: './images/sb4.jpg' },
        { url: './images/s5.jpg', bg: './images/sb5.jpg' },
        { url: './images/s6.jpg', bg: './images/sb6.jpg' },
        { url: './images/s7.jpg', bg: './images/sb7.jpg' },
        { url: './images/s8.jpg', bg: './images/sb8.jpg' },
        { url: './images/s9.jpg', bg: './images/sb9.jpg' },
        { url: './images/s10.jpg', bg: './images/sb10.jpg' },

      ]
      // 获取图片元素
      const img = document.querySelector('.slider .wrap img')
      const ban = document.querySelector('.slider .n-ban');
      // 左右按钮
      const next = document.querySelector('.next')
      const prev = document.querySelector('.prev')
      let i = 0;//控制图片播放张数

      //声明一个渲染的函数作为复用
      function common() {
        img.src = sliderData[i].url;
        ban.style.backgroundImage = `url(${sliderData[i].bg})`;
        // 更换小圆点
        document.querySelector('.dots .active').classList.remove('active');
        document.querySelector(`.dots li:nth-child(${i + 1})`).classList.add('active');
      }
      next.addEventListener('click', function () {
        i++;
        i %= sliderData.length;
        common();
      })
      prev.addEventListener('click', function () {
        i--;
        if (i < 0) {
          i = sliderData.length - 1;
        }
        common();
      })

      // 自动播放
      let timer = setInterval(function () {
        // 利用js自动调用点击事件
        next.click();
      }, 1000)
      // 鼠标经过，停止定时器
      const slider = document.querySelector('.slider');
      slider.addEventListener('mouseenter', function () {
        clearInterval(timer);
      })
      // 鼠标离开，开启定时器
      slider.addEventListener('mouseleave', function () {
        timer = setInterval(function () {
          next.click();
        }, 1000)
      })
    });
  </script>
</body>

</html>